package com.thoughworks.biblioteca.utils;

import java.io.BufferedReader;
import java.io.IOException;

import com.thoughtworks.biblioteca.exceptions.IllegalSelectionNumberException;

/**
 * A Helper Class. It contains the common used methods.
 * 
 */
public class HelperUtil {
	public static int getInput(BufferedReader bufferedReader)
			throws IllegalSelectionNumberException {
		try {
			String input = bufferedReader.readLine();
			if (input != null && !"".equals(input)) {
				return Integer.parseInt(input.trim());
			} else
				return 0;
		} catch (NumberFormatException e) {
			throw new IllegalSelectionNumberException(
					"\nEnter a valid integer!!");
		} catch (IOException e) {
			System.out.println("Someting wrong with IO!!");
			return 0;
		}
	}
}
